/*
 * Copyright (C) 2021 The Chinese Software International Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tonyodev.fetch2;

/**
 * description NetworkType
 *
 * @author liuluming
 * @since 2021-05-20
 */

public enum NetworkType {
    /**
     * Indicates a network type that is not bounded. This is used by Fetch
     * to disable the global network type option allowing each download to indicate
     * their own network type they can download on.
     */
    GLOBAL_OFF(-1),

    /**
     * Indicates that a download can be downloaded over mobile or wifi networks.
     */
    ALL(0),

    /**
     * Indicates that a download can be downloaded only on wifi networks.
     */
    WIFI_ONLY(1),

    /**
     * Indicates that a download can be downloaded only on an unmetered connection.
     */
    UNMETERED(2);

    int value;

    NetworkType(int value) {

    }

    public final int getValue() {
        return this.value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    /**
     * valueOf
     *
     * @param value value
     * @return true
     */
    public static NetworkType valueOf(int value) {
        NetworkType mNetworkType;
        switch (value) {
            case -1:
                mNetworkType = NetworkType.GLOBAL_OFF;
                break;
            case 0:
                mNetworkType = NetworkType.ALL;
                break;
            case 1:
                mNetworkType = NetworkType.WIFI_ONLY;
                break;
            case 2:
                mNetworkType = NetworkType.UNMETERED;
                break;
            default:
                mNetworkType = NetworkType.ALL;
        }
        return mNetworkType;

    }
}
